<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>电影列表</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <style>
        .movie-card {
            margin-bottom: 20px;
        }
        .movie-poster {
            height: 300px;
            object-fit: cover;
        }
        .section-title {
            margin: 30px 0 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="/">电影系统</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="/movie/list">电影列表</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/user/list">用户管理</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2>电影列表</h2>
            <a href="/movie/add" class="btn btn-primary">添加电影</a>
        </div>

        <!-- 电影类型筛选 -->
        <div class="mb-3">
            <a href="/movie/list" class="btn btn-outline-secondary">全部</a>
            <a href="/movie/type/动作" class="btn btn-outline-secondary">动作</a>
            <a href="/movie/type/喜剧" class="btn btn-outline-secondary">喜剧</a>
            <a href="/movie/type/科幻" class="btn btn-outline-secondary">科幻</a>
            <a href="/movie/type/爱情" class="btn btn-outline-secondary">爱情</a>
        </div>

        <div class="row">
            <div th:each="movie : ${movies}" class="col-md-3 movie-card">
                <div class="card">
                    <img th:src="${movie.photo}" class="card-img-top movie-poster" alt="电影海报">
                    <div class="card-body">
                        <h5 class="card-title" th:text="${movie.name}">电影名称</h5>
                        <p class="card-text" th:text="${movie.description}">电影简介</p>
                        <div class="d-flex justify-content-between">
                            <a th:href="@{'/movie/detail/' + ${movie.id}}" class="btn btn-primary">查看详情</a>
                            <a th:href="@{'/movie/edit/' + ${movie.id}}" class="btn btn-secondary">编辑</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
